//This macro converts files from Eastern Language Systems' now defunct "Al-Kaatib" for Macintosh format to a WorldScript compatible format. To use this macro, first save your Al-Kaatib file as text. Then open the text in Nisus and run this macro. If you show the Info bar before running the macro, you will get an indication of the macro’s rate of progress.
//The macro is not very fast. On my Quadra 800, it processes about 23,000 characters per hour. It's best to run the macro when you won't need your computer for anything else for a while. You can paste the plain text of several Al-Kaatib files into a Nisus window and let the macro run overnight. Choose Info Bar from the Display submenu of the Tools menu so you can guage the progress of the macro.
//If paragraphs in your original Al-Kaatib file are not separated by a blank line, you will need to add hard returns to re-define your paragraphs after the macro has run.
//In the above documentation, I put the comment indicators "//" in the "Invisible" format.
c = "" //this text variable must be initialized. It will be used in the appendIt label below.
//go to beginning of document:
Key
loopA:
//go to beginning of paragraph:
Key
beginPara = CharNum
//go to end of paragraph:
Key
endPara = CharNum
a = endPara-beginPara
if (a==0) GoTo nextPara
SetSelect (beginPara,endPara)
MacroCopy
text = clipboard
loopB:
currentChar = right (text, 1)
//ASCII conversion begins here
//I examined a sample Persian text with about 10,000 characters to determine which characters occurred most frequently. I put the most frequently occurring characters at the beginning, and those that occurred very infrequently or not at all at the end. As of 6 March 1995, the complete sequence has not been optimized. However, further optimization of the order is unlikely to yield a significant performance increase.
asciiValue = CharToNum (currentChar)
If (asciiValue == 32) GoTo appendIt
If (asciiValue == 90) currentChar = NumToChar (199); GoTo appendIt
If (asciiValue == 163) currentChar = NumToChar (199); GoTo appendIt
If (asciiValue == 122) currentChar = NumToChar (232); GoTo appendIt
If (asciiValue == 172) currentChar = NumToChar (207); GoTo appendIt
If (asciiValue == 174) currentChar = NumToChar (209); GoTo appendIt
If (asciiValue == 133) currentChar = NumToChar (200); GoTo appendIt
If (asciiValue == 100) currentChar = NumToChar (207); GoTo appendIt
If (asciiValue == 228) currentChar = NumToChar (231); GoTo appendIt
If (asciiValue == 156) currentChar = NumToChar (230); GoTo appendIt
If (asciiValue == 160) currentChar = NumToChar (234); GoTo appendIt
If (asciiValue == 102) currentChar = NumToChar (209); GoTo appendIt
If (asciiValue == 155) currentChar = NumToChar (229); GoTo appendIt
If (asciiValue == 194) currentChar = NumToChar (232); GoTo appendIt
If (asciiValue == 152) currentChar = NumToChar (227); GoTo appendIt
If (asciiValue == 197) currentChar = NumToChar (233); GoTo appendIt
If (asciiValue == 231) currentChar = NumToChar (233); GoTo appendIt
If (asciiValue == 177) currentChar = NumToChar (211); GoTo appendIt
If (asciiValue == 205) currentChar = NumToChar (202); GoTo appendIt
If (asciiValue == 120) currentChar = NumToChar (230); GoTo appendIt
If (asciiValue == 157) currentChar = NumToChar (231); GoTo appendIt
If (asciiValue == 44) currentChar = NumToChar (172); GoTo appendIt
If (asciiValue == 103) currentChar = NumToChar (210); GoTo appendIt
If (asciiValue == 142) currentChar = NumToChar (212); GoTo appendIt
If (asciiValue == 137) currentChar = NumToChar (204); GoTo appendIt
If (asciiValue == 165) currentChar = NumToChar (202); GoTo appendIt
If (asciiValue == 134) currentChar = NumToChar (202); GoTo appendIt
If (asciiValue == 136) currentChar = NumToChar (243); GoTo appendIt
If (asciiValue == 138) currentChar = NumToChar (205); GoTo appendIt
If (asciiValue == 139) currentChar = NumToChar (206); GoTo appendIt
If (asciiValue == 140) currentChar = NumToChar (245); GoTo appendIt
If (asciiValue == 141) currentChar = NumToChar (211); GoTo appendIt
If (asciiValue == 143) currentChar = NumToChar (213); GoTo appendIt
If (asciiValue == 144) currentChar = NumToChar (214); GoTo appendIt
If (asciiValue == 145) currentChar = NumToChar (215); GoTo appendIt
If (asciiValue == 147) currentChar = NumToChar (217); GoTo appendIt
If (asciiValue == 148) currentChar = NumToChar (218); GoTo appendIt
If (asciiValue == 149) currentChar = NumToChar (225); GoTo appendIt
If (asciiValue == 150) currentChar = NumToChar (226); GoTo appendIt
If (asciiValue == 153) currentChar = NumToChar (248); GoTo appendIt
If (asciiValue == 154) currentChar = NumToChar (228); GoTo appendIt
If (asciiValue == 158) currentChar = NumToChar (234); GoTo appendIt
If (asciiValue == 161) currentChar = NumToChar (198); GoTo appendIt
If (asciiValue == 164) currentChar = NumToChar (200); GoTo appendIt
If (asciiValue == 166) currentChar = NumToChar (203); GoTo appendIt
If (asciiValue == 167) currentChar = NumToChar (243); GoTo appendIt
If (asciiValue == 168) currentChar = NumToChar (204); GoTo appendIt
If (asciiValue == 169) currentChar = NumToChar (205); GoTo appendIt
If (asciiValue == 170) currentChar = NumToChar (206); GoTo appendIt
If (asciiValue == 171) currentChar = NumToChar (245); GoTo appendIt
If (asciiValue == 173) currentChar = NumToChar (208); GoTo appendIt
If (asciiValue == 175) currentChar = NumToChar (210); GoTo appendIt
If (asciiValue == 178) currentChar = NumToChar (212); GoTo appendIt
If (asciiValue == 179) currentChar = NumToChar (213); GoTo appendIt
If (asciiValue == 180) currentChar = NumToChar (214); GoTo appendIt
If (asciiValue == 181) currentChar = NumToChar (215); GoTo appendIt
If (asciiValue == 183) currentChar = NumToChar (217); GoTo appendIt
If (asciiValue == 184) currentChar = NumToChar (218); GoTo appendIt
If (asciiValue == 185) currentChar = NumToChar (225); GoTo appendIt
If (asciiValue == 186) currentChar = NumToChar (226); GoTo appendIt
If (asciiValue == 188) currentChar = NumToChar (227); GoTo appendIt
If (asciiValue == 189) currentChar = NumToChar (248); GoTo appendIt
If (asciiValue == 190) currentChar = NumToChar(228); GoTo appendIt
If (asciiValue == 191) currentChar = NumToChar (229); GoTo appendIt
If (asciiValue == 192) currentChar = NumToChar (230); GoTo appendIt
If (asciiValue == 193) currentChar = NumToChar (231); GoTo appendIt
//uncertain what character ASCII 202 represents
If (asciiValue == 202) currentChar = NumToChar (199); GoTo appendIt
//uncertain what character ASCII 203 represents
If (asciiValue == 203) currentChar = NumToChar (198); GoTo appendIt
If (asciiValue == 204) currentChar = NumToChar (200); GoTo appendIt
If (asciiValue == 206) currentChar = NumToChar (203); GoTo appendIt
If (asciiValue == 211) currentChar = NumToChar (245); GoTo appendIt
If (asciiValue == 212) currentChar = NumToChar (211); GoTo appendIt
If (asciiValue == 213) currentChar = NumToChar (212); GoTo appendIt
If (asciiValue == 214) currentChar = NumToChar (213); GoTo appendIt
If (asciiValue == 216) currentChar = NumToChar (215); GoTo appendIt
If (asciiValue == 218) currentChar = NumToChar (217); GoTo appendIt
If (asciiValue == 220) currentChar = NumToChar (225); GoTo appendIt
If (asciiValue == 221) currentChar = NumToChar (226); GoTo appendIt
If (asciiValue == 223) currentChar = NumToChar (227); GoTo appendIt
If (asciiValue == 225) currentChar = NumToChar (228); GoTo appendIt
If (asciiValue == 226) currentChar = NumToChar (229); GoTo appendIt
If (asciiValue == 227) currentChar = NumToChar (230); GoTo appendIt
If (asciiValue == 253) currentChar = ""; GoTo appendIt
//ASCII 254 unknown
If (asciiValue == 254) currentChar = ""; GoTo appendIt
//ASCII 255 unknown
If (asciiValue == 255) currentChar = ""; GoTo appendIt
//ASCII conversion ends here
appendIt:
c = c + currentChar
a = a-1
text = left (text, a)
if (a>0) GoTo loopB
pasteIt:
clipboard = c
c = "" //re-initializing c
MacroPaste
nextPara:
Key
endCheck = CharNum
Key
if (CharNum==endCheck) GoTo stripLineFeeds
GoTo loopA
stripLineFeeds:
Select All
//Next we strip line feeds. If paragraphs in the original Al-Kaatib file were not separated by a blank line, then they will be combined into one large paragraph. When Al-Kaatib exports text, it puts a hard return at the end of each line, thus it is impossible to determine which hard returns are merely line breaks and which ones define new paragraphs. You may have to edit your converted file to re-define your paragraphs. Note that each line of Al-Kaatib exported text begins with a space, so we don’t need to replace line feeds with a space; we simply remove them.
Find/Replace ":<[^\r]\r:>[^\r]" "" "gtsA"
changeFont:
//This routine changes all text to the «‰‚«Á—… font.
«‰‚«Á—…
//Choose the «‰‚«Á—… (Al-Qahira) font while holding the shift key. I chose this font because you’re likely to have it. If your text was in Persian characters, you will want to change to a Persian font, because the Arabic fonts don't have the Persian "narrow space" or "heh-hamzeh."
Right to Left
//Changes text flow direction
Key
//Go to the beginning of the document, whilesimultaneously deselecting all text.